package classes.managers {
	import classes.global.GlobalProperties;
	import classes.scenes.A_Scene;
	import flash.display.MovieClip;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	
	/**
	 * ...
	 * @author Kihoonee
	 */
	public class CoinView_Manager extends A_Scene {
		
		
		
		public function CoinView_Manager( _main:Main, _mc:MovieClip ) {
			super( _main, _mc );
			
		}
		
		public function init():void {
			mc.gotoAndStop(2);
			
			visible = true;
			var timer:Timer = new Timer( 2000, 1 );
			timer.addEventListener(TimerEvent.TIMER_COMPLETE, function(e:TimerEvent):void {
				timer.removeEventListener(TimerEvent.TIMER_COMPLETE, arguments.callee );
				
				visible = false;
				main.rankInit();
			});
			timer.start();
			
			coinCount( GlobalProperties.coin, mc.coins_mc );
		}
		private function coinCount( _cnt:int, _mc:MovieClip ):void {
			trace("coinView : ", _cnt)
			
			var str:String;
			var num10000:String;
			var num1000:String;
			var num100:String;
			var num10:String;
			var num1:String;
			
			if ( _cnt < 10 ) {
				_mc.num1_mc.gotoAndStop( _cnt + 1 );
			}else if ( _cnt >= 10 && _cnt < 100 ) {
				str = String( _cnt );
				num10 = str.substr(0, 1);
				num1 = str.substr(1, 1);
				
				if( Number(num10) === 0 ) _mc.num10_mc.gotoAndStop( 1 );
				else _mc.num10_mc.gotoAndStop( Number(num10)+1 );
				
				if( Number(num1) === 0 ) _mc.num1_mc.gotoAndStop( 1 );
				else _mc.num1_mc.gotoAndStop( Number(num1)+1 );
			}else if ( _cnt >= 100 && _cnt < 1000 ) {
				str = String( _cnt );
				num100 = str.substr(0, 1);
				num10 = str.substr(1, 1);
				num1 = str.substr(2, 1);
				
				if( Number(num100) === 0 ) _mc.num100_mc.gotoAndStop( 1 );
				else _mc.num100_mc.gotoAndStop( Number(num100) + 1 );
				
				if( Number(num10) === 0 ) _mc.num10_mc.gotoAndStop( 1 );
				else _mc.num10_mc.gotoAndStop( Number(num10)+1 );
				
				if( Number(num1) === 0 ) _mc.num1_mc.gotoAndStop( 1 );
				else _mc.num1_mc.gotoAndStop( Number(num1)+1 );
			}else if ( _cnt >= 1000 && _cnt < 10000 ) {
				str = String( _cnt );
				num1000 = str.substr(0, 1);
				num100 = str.substr(1, 1);
				num10 = str.substr(2, 1);
				num1 = str.substr(3, 1);
				
				if( Number(num1000) === 0 ) _mc.num1000_mc.gotoAndStop( 1 );
				else _mc.num1000_mc.gotoAndStop( Number(num1000) + 1 );
				
				if( Number(num100) === 0 ) _mc.num100_mc.gotoAndStop( 1 );
				else _mc.num100_mc.gotoAndStop( Number(num100) + 1 );
				
				if( Number(num10) === 0 ) _mc.num10_mc.gotoAndStop( 1 );
				else _mc.num10_mc.gotoAndStop( Number(num10)+1 );
				
				if( Number(num1) === 0 ) _mc.num1_mc.gotoAndStop( 1 );
				else _mc.num1_mc.gotoAndStop( Number(num1)+1 );
			}/*else if ( _cnt >= 10000 && _cnt < 100000 ) {
				str = String( _cnt );
				num10000 = str.substr(0, 1);
				num1000 = str.substr(1, 1);
				num100 = str.substr(2, 1);
				num10 = str.substr(3, 1);
				num1 = str.substr(4, 1);
				
				if( Number(num10000) === 0 ) _mc.num10000_mc.gotoAndStop( 1 );
				else _mc.num10000_mc.gotoAndStop( Number(num10000) + 1 );
				
				if( Number(num1000) === 0 ) _mc.num1000_mc.gotoAndStop( 1 );
				else _mc.num1000_mc.gotoAndStop( Number(num1000) + 1 );
				
				if( Number(num100) === 0 ) _mc.num100_mc.gotoAndStop( 1 );
				else _mc.num100_mc.gotoAndStop( Number(num100) + 1 );
				
				if( Number(num10) === 0 ) _mc.num10_mc.gotoAndStop( 1 );
				else _mc.num10_mc.gotoAndStop( Number(num10)+1 );
				
				if( Number(num1) === 0 ) _mc.num1_mc.gotoAndStop( 1 );
				else _mc.num1_mc.gotoAndStop( Number(num1)+1 );
			}*/
		}
	}

}